<!-- 引入命名空间，将静态页面转换为动态的视图 -->
<html xmlns:th="http://www.thymeleaf.org">
<head>
 <meta content="text/html;charset=UTF-8"></meta>
 <meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
 <meta name="viewport" content="width=device-width,initial-scale=1"></meta>
 
 <link th:href="@{asset/bootstrap-3.3.7-dist/css/bootstrap.css}" rel="stylesheet"></link>
 
 <link th:href="@{asset/bootstrap-3.3.7-dist/css/bootstrap-theme.css}" rel="stylesheet"></link>

</head>
<body>
<div class="panel panel-primary">
 <div class="panel-heading">
   <h3 class="panel-title">访问model</h3>
 </div>
 <div class="pannel-body">
   <span th:text="${singlePerson.name}"></span>
 </div>
</div>

<div th:if="${not #lists.isEmpty(people)}">
 <div class="panel panel-primary">
  <div class="panel-heading">
    <h3 class="pannel-title">列表</h3>
  </div>
  <div class="panel-body">
   <ul class="list-group">
    <li class="list-group-item" th:each="person:${people}">
      <span th:text="${person.name}"></span>
      <span th:text="${person.age}"></span>
      <button class="btn" th:onclick="'getName(\'' + ${person.name} + '\');'">获得名字</button>
    </li>
   </ul>
  </div>
 </div>
</div>


</body>
<script type="text/javascript" th:src="@{asset/jquery-3.2.1/jquery-3.2.1.js}"></script>
<script type="text/javascript" th:src="@{asset/bootstrap-3.3.7-dist/js/bootstrap.js}"></script>

<script th:inline="javascript">
 var single = [[${singlePerson}]];
 console.log(single.name + "/" + single.age);
 
 function getName(name){
	 console.log(name);
 }
</script>

</html>